<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="_fragment::head(~{::title})">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta charset="UTF-8">
    <title>订单管理</title>
</head>

<body class="no-skin">

<!--导航部分-->
<div th:replace="_fragment :: nav"></div>

<!--页面主体-->
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <!--侧边栏-->
    <div th:replace="_fragment :: menu(4,4.1)"></div>

    <!--主页中心部分-->
    <div class="main-content" >

        <!--面包屑-->
        <div class="breadcrumbs" id="breadcrumbs">
            <script type="text/javascript">
                try {
                    ace.settings.check('breadcrumbs', 'fixed')
                } catch (e) {
                }
            </script>

            <!--多级导航-->
            <ul class="breadcrumb">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a th:href="@{/admin/toIndex}">首页</a>
                </li>
                <li class="active">订单列表</li>
            </ul><!-- /.breadcrumb -->
        </div>

        <!--中心内容	-->
        <div class="page-content">
            <!--设置-->
<!--            <div th:replace="_fragment::setting"></div>-->

            <div class="page-content-area">

                <div class="row">
                    <div class="col-xs-12">
                        <!-- 页面内容开始 -->

                        <!--内容	-->
                        <div class="row">
                            <div class="col-xs-12">
                                <h3 class="header smaller lighter blue">订单列表
                                    <form th:action="@{/admin/searchOrder}"  th:method="post">
                                        <div class="mdui-textfield" style="position: absolute; width: 300px;right: 230px;top: -7px;">
                                            <input class="mdui-textfield-input" type="text" id="userName" name="userName" placeholder="输入订单用户查询.." required/>
                                        </div>
                                        <button type="submit" class="mdui-btn mdui-btn-raised mdui-ripple" style="position: absolute;right: 138px;top: 8px;"><i class="mdui-icon material-icons">search</i></button>
                                    </form>
                                    <form id="downloadOrder" th:action="@{/admin/downloadOrder}"  th:method="post"></form>
                                    <button onclick="subForm()" class="mdui-btn mdui-btn-raised mdui-ripple" style="position: absolute;right: 14px;top: 8px;" />导出全部订单</button>
                                </h3>
                                <div class="table-header">
                                    》
                                </div>
                                <div>
                                    <div id="sample-table-2_wrapper" class="dataTables_wrapper form-inline" role="grid">

                                        <table id="sample-table-2"
                                               class="mdui-table mdui-table-selectable mdui-table-hoverable"
                                               aria-describedby="sample-table-2_info">
                                            <!--表格头-->
                                            <thead>
                                            <tr>
                                                <th class="mdui-table-col-numeric sorting_disabled" role="columnheader" tabindex="0"
                                                    aria-controls="sample-table-2" rowspan="1" colspan="1"
                                                    aria-label="Domain: activate to sort column ascending">创建时间
                                                </th>
                                                <th class="mdui-table-col-numeric sorting_disabled" role="columnheader" tabindex="0"
                                                    aria-controls="sample-table-2" rowspan="1" colspan="1"
                                                    aria-label="Domain: activate to sort column ascending">订单号
                                                </th>
                                                <th class="mdui-table-col-numeric sorting_disabled" role="columnheader" tabindex="0"
                                                    aria-controls="sample-table-2" rowspan="1" colspan="1"
                                                    aria-label="Price: activate to sort column ascending">买家
                                                </th>
                                                <th class="mdui-table-col-numeric sorting_disabled" role="columnheader" tabindex="0"
                                                    aria-controls="sample-table-2" rowspan="1" colspan="1"
                                                    aria-label="Clicks: activate to sort column ascending">总额
                                                </th>
                                                <th class="mdui-table-col-numeric sorting_disabled" role="columnheader" tabindex="0"
                                                    aria-controls="sample-table-2" rowspan="1" colspan="1"
                                                    aria-label="Status: activate to sort column ascending">订单状态
                                                </th>
                                                <th class="mdui-table-col-numeric sorting_disabled" role="columnheader" tabindex="0"
                                                    aria-controls="sample-table-2" rowspan="1" colspan="1"
                                                    aria-label="Status: activate to sort column ascending">支付状态
                                                </th>
                                                <th class="mdui-table-col-numeric sorting_disabled" role="columnheader" tabindex="0"
                                                    aria-controls="sample-table-2" rowspan="1" colspan="1"
                                                    aria-label="Status: activate to sort column ascending">详情
                                                </th>
                                            </tr>
                                            </thead>

                                            <tbody role="alert" aria-live="polite" aria-relevant="all">
                                                <tr class="" th:each="order,stat : ${iPage.records}" th:classappend="${stat.index %2== 0 ? 'odd':'even'}">
                                                    <td class=""th:text="${#dates.format(order.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                                    <td class=""th:text="${order.orderNum}">app.com</td>
                                                    <td class="" th:text="${order.userName}">$45</td>
                                                    <td class="" th:text="'￥'+${order.amountStr}">$45</td>
                                                    <td class="hidden-480 " th:text="${order.orderStatusStr}">3,330</td>
                                                    <td class="hidden-480 " th:text="${order.payStatusStr}">3,330</td>
                                                    <td>
                                                        <div class="hidden-sm hidden-xs action-buttons">
                                                            <a class="blue" href="#" th:href="@{/admin/queryOrderDetail/{id}(id=${order.id})}">
                                                                <i class="mdui-icon material-icons">search</i>
                                                            </a>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>

                                        <!--分页条-->
                                        <div class="row mdui-table">
                                            <div class="col-xs-6">
                                                <div class="dataTables_info" id="sample-table-2_info">
                                                    总条数:&nbsp;[[${iPage.total}]]&nbsp;条
                                                </div>
                                            </div>
                                            <div class="col-xs-6">
                                                <div class="dataTables_paginate paging_bootstrap">
                                                    <ul class="pagination">
                                                        <!--首页-->
                                                        <li class="prev" th:classappend="${iPage.current == 1 ? 'disabled' : ''}">
                                                            <a href="#" th:href="@{/admin/toOrder(p=1,s=${iPage.size})}">
                                                                <i class="fa fa-angle-double-left"></i>
                                                            </a>
                                                        </li>
                                                        <!--上一页-->
                                                        <li class="prev" th:classappend="${iPage.current == 1 ? 'disabled' : ''}">
                                                            <a href="#" th:href="@{/admin/toOrder(p=${iPage.current}-1,s=${iPage.size})}">
                                                                <i class="fa fa-angle-left"></i>
                                                            </a>
                                                        </li>
                                                        <!--页码-->
                                                        <li class="" th:each="i:${#numbers.sequence(1,iPage.pages)}" th:classappend="${iPage.current == i ? 'active':''}">
                                                            <a href="#" th:href="@{/admin/toOrder(p=${i},s=${iPage.size})}" th:text="${i}">1</a>
                                                        </li>
                                                        <!--下一页-->
                                                        <li class="next" th:classappend="${iPage.current == iPage.pages ? 'disabled' : ''}">
                                                            <a href="#" th:href="@{/admin/toOrder(p=${iPage.current == iPage.pages ? iPage.pages : iPage.current+1},s=${iPage.size})}">
                                                                <i class="fa fa-angle-right"></i>
                                                            </a>
                                                        </li>
                                                        <!--尾页-->
                                                        <li class="next" th:classappend="${iPage.current == iPage.pages ? 'disabled' : ''}">
                                                            <a href="#" th:href="@{/admin/toOrder(p=${iPage.pages},s=${iPage.size})}">
                                                                <i class="fa fa-angle-double-right"></i>
                                                            </a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content-area -->
        </div><!-- /.page-content -->
    </div><!-- /.main-content -->

    <!--页脚	-->
    <div th:replace="_fragment::footer"></div>

    <!--回到顶部-->
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>
</div><!-- /.main-container -->

<!--引入js	-->
<th:block th:replace="_fragment::script"></th:block>

<script>
    function del(id) {
        bootbox.confirm("你确定要删除该用户？",function (res) {
            if(res){
                window.location.href = "/admin/deleteUser/"+id;
            }
        })
    }
    function subForm(){
        $.ajax({
            type: "POST",
            url: "/admin/exportOrder",
            data: {
            },
            success: function (res) {
                if (res ===1) {
                    into();//导出完成，并下载
                }else{
                    alert("导出失败！");
                }
            }
        });
    }
    function into() {
        $('#downloadOrder').submit();//导出表单
    }
</script>

</body>
</html>
